package com.freecat.xmqgct.mvp.model;

import com.freecat.xmqgct.mvp.model.api.Api;
import com.freecat.xmqgct.mvp.model.entity.BaseResponse;
import com.freecat.xmqgct.mvp.model.entity.FileBean;
import com.freecat.xmqgct.mvp.model.entity.LoginBean;


import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import me.jessyan.art.mvp.IModel;
import me.jessyan.art.mvp.IRepositoryManager;
import okhttp3.MultipartBody;
import retrofit2.http.QueryMap;

/**
 * ================================================
 * 必须实现 IModel
 * 可以根据不同的业务逻辑划分多个 Repository 类, 多个业务逻辑相近的页面可以使用同一个 Repository 类
 * 无需每个页面都创建一个独立的 Repository
 * 通过 {@link me.jessyan.art.mvp.IRepositoryManager#createRepository(java.lang.Class)} 获得的 Repository 实例, 为单例对象
 * <p>
 * Created by MVPArtTemplate on 09/16/2019 10:08
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArt">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */

public class LoginRepository implements IModel {
    private IRepositoryManager mManager;

    public LoginRepository(IRepositoryManager manager) {
        this.mManager = manager;
    }

    public Observable<BaseResponse<FileBean>> upload(String rybh, String xmbh, MultipartBody.Part part) {
        return mManager.createRetrofitService(Api.class).upload(rybh, xmbh, part);
    }

    public Observable<BaseResponse<LoginBean>> login(String mobile, String password) {
        return mManager.createRetrofitService(Api.class).login(mobile, password);
    }


    public Observable<BaseResponse<LoginBean>> lw_login(@QueryMap Map<String, String> map) {
        return mManager.createRetrofitService(Api.class).lw_login(map);
    }

//    public Observable<BaseResponse<UpdateBean>> checkUpdate(String rybh) {
//        return mManager.createRetrofitService(Api.class).checkUpdate(rybh);
//    }
//
//    public Observable<BaseResponse<UserIdBean>> register(String mobile, String password, String dwmc, String sfzh,
//                                                         String ryxm, String rytx) {
//        return mManager.createRetrofitService(Api.class).register(mobile, password, dwmc, sfzh, ryxm, rytx);
//    }
//
//
//    public Observable<BaseResponse<UserIdBean>> register_nj(String mobile, String password, String dwmc, String sfzh,
//                                                         String ryxm,String category,MultipartBody.Part rytx) {
//        System.out.println("nj=====注册步骤2");
//        return mManager.createRetrofitService(Api.class).register_nj(mobile, password, dwmc, sfzh, ryxm,category,rytx);
//    }
//
//
//    public Observable<BaseResponse<List<UnitNameBean>>> getDwmcList(String dwmc) {
//        return mManager.createRetrofitService(Api.class).getDwmcList(dwmc);
//    }
//
//    public Observable<BaseResponse<LoginBean>> getUserDetail(String dwmc) {
//        return mManager.createRetrofitService(Api.class).getUserDetail(dwmc);
//    }
//
//    public Observable<BaseResponse> CheckIn(String rybh, String xmbh, String kqrq, String jc_jd, String jc_wd, String jc_dz,String yzzt) {
//        return mManager.createRetrofitService(Api.class).CheckIn(rybh, xmbh, kqrq, jc_jd, jc_wd, jc_dz,yzzt);
//    }

    @Override
    public void onDestroy() {

    }
}
